/**
 * 
 */
package net.looker.monitor.schdule;


import net.looker.work.Work;

/**
 * 监视器的父类
 * @author solosky
 *
 */
public abstract class Monitor implements Work
{
	/**
	 * 监视器的编号
	 * 唯一的
	 */
	protected String hash;
	
	/**
	 * 监视器的名称
	 */
	protected String name;
	
	/**
	 * 更新间隔
	 */
	protected long interval;
	
	/**
	 * 监视器的状态
	 */
	protected volatile STATUS status;
	
	/**
	 * 操作
	 */
	protected volatile ACTION action;
	
	
	
	
	/**
	 * 运行状态 
	 */
	public static  enum STATUS {RUN, STOP, PAUSE};
	
	/**
	 * 当前操作
	 */
	public static enum ACTION { WAITING, MONITOR };
	
	/**
	 * 构造函数
	 * @param name
	 * @param hash
	 */
	public Monitor(String name, String hash, long interval)
	{
		this.name = name;
		this.hash = hash;
		this.interval = interval;
		this.status = STATUS.RUN;
		this.action = ACTION.WAITING;
	}
	
	/**
	 * 返回监视器状态
	 */
	public STATUS getStatus()
	{
		return status;
	}
	
	/**
	 * 返回当前监视器操作
	 */
	public ACTION getAction()
	{
		
		return this.action;
	}
	/**
	 * 返回监视器编号
	 */
	public String getHash()
	{
		return  hash;
	}
	
	/**
	 * 返回监视器的间隔
	 */
	public long getInterval()
	{
		return interval;
	}
	
	/**
	 * 设置监视器的编号
	 */
	public void setHash(String hash)
	{
		this.hash = hash;
	}
	
	/* (non-Javadoc)
	 * @see net.looker.work.worker#startWork()
	 */
	@Override
	public void startWork()
	{
		startMonitor();
	}
	
	/* (non-Javadoc)
	 * @see net.looker.work.worker#startWork()
	 */
	@Override
	public boolean isFinished()
	{
		return false;
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * 开始监视
	 * @return 
	 */
	public abstract void startMonitor();
}
